<!DOCTYPE html>
<html>
<head>
<#include "/layout/publicres.html"/>
</head>
<body class="easyui-layout" id="bodyLayout">
	<!-- begin of header -->
	<div class="wu-header" data-options="region:'north',border:false,split:true">
    	<div class="wu-header-left">
        	<h1 >xx系统</h1>
        </div>
        <div class="wu-header-right">
        	<p><strong>${user.name}</strong>，欢迎您！</p>
<!--         	<p><strong><@shiro.principal/></strong>，欢迎您！</p> -->
            <p><a href="javascript:;" id="cpass">修改密码</a>&nbsp;|&nbsp;<a href="user/logout">安全退出</a></p>
        </div>
    </div>
    <!-- end of header -->
    <!-- begin of sidebar -->
    
	<div  class="wu-sidebar" data-options="region:'west',split:true,border:true,title:'导航菜单'" > 
    	<div class="easyui-accordion" data-options="border:false,fit:true"> 
    	  <#list menuData as m> 
	        	<div title="${m.title}" data-options="iconCls:'${m.icon}'" style="padding:5px;">  	
	    			<ul class="easyui-tree wu-side-tree">
		    			 <#list m.children as c>
		                	<li iconCls="${c.icon}"><a href="javascript:void(0)" data-icon="${c.icon?default('')}" data-link="${c.href}" iframe="${c.isiframe}">${c.title}</a></li>
		                  </#list> 
	                </ul>
	            </div>
           </#list>
        </div>
    </div>	
    
    
    <!-- end of sidebar -->    
    <!-- begin of main -->
    <div   data-options="region:'center'">
        <div id="wu-tabs" class="easyui-tabs" data-options="border:false,fit:true">  
<!--             <div title="首页" data-options="href:'http://www.baidu.com'"> -->
            <div title="首页">
            <!-- <div title="预警信息" data-options="href:'warn/wlist'"> -->
			</div>
        </div>
    </div>
    
    <!--begin 修改密码  -->
    <div id="pwd-page"></div>
    <!--end 修改密码  -->
    
    <!-- end of main --> 
    
<!--     <div class="wu-footer" data-options="region:'south',border:true,split:true"> -->
<!--     	&copy; 2013 Wu All Rights Reserved -->
<!--     </div> -->
    <!-- end of footer -->  
    
 
    <script type="text/javascript">
		$(function(){
			//菜单绑定点击事件，新增tab
			$('.wu-side-tree li').bind("click",function(){
				var title = $(this).find("a").text();
				var url = $(this).find("a").attr('data-link');
				var iconCls = $(this).find("a").attr('data-icon');
				var iframe = $(this).find("a").attr('iframe')==1?true:false;
				addTab(title,url,iconCls,iframe);
			});	
			//修改密码
			$("#cpass").click(function(){
				$('#pwd-page').dialog({
					closed: false,
					modal:true,
		            title: "修改密码",
		            href:"user/toupdatePass",
		            width:400,
		            height:250
		        });
			});

		})
		
		
		/**
		* Name 选项卡初始化
		*/
		$('#wu-tabs').tabs({
			tools:[{
				iconCls:'icon-reload',
				border:false,
				handler:function(){
					$('#wu-datagrid').datagrid('reload');
				}
			}]
		});
			
		/**
		* Name 添加菜单选项
		* Param title 名称
		* Param href 链接
		* Param iconCls 图标样式
		* Param iframe 链接跳转方式（true为iframe，false为href）
		*/	
		function addTab(title, href, iconCls, iframe){
			var tabPanel = $('#wu-tabs');
			if(!tabPanel.tabs('exists',title)){
				var content = '<iframe scrolling="no" frameborder="0"  src="'+ href +'" style="width:100%;height:99%; overflow:hidden"></iframe>';
				//是否需要单独iframe展示
				if(iframe){
					tabPanel.tabs('add',{
						title:title,
						content:content,
						iconCls:iconCls,
						fit:true,
						closable:true
					});
				}
				else{
					tabPanel.tabs('add',{
						title:title,
						href:href,
						iconCls:iconCls,
						fit:true,
						closable:true
					});
				}
			}
			else{
				tabPanel.tabs('select',title);
			}
// 			else
// 			{
// 				var currTab = tabPanel.tabs('getSelected');  
// 				tabPanel.tabs('select',title);
// 				if(iframe){
// 					tabPanel.tabs('update', {
// 						tab : currTab,
// 						options : {
// 							content : '<iframe scrolling="auto" frameborder="0"  src="'+ href +'" style="width:100%;height:100%;"></iframe>'
// 						}
// 					});
// 				}else{
// 					tabPanel.tabs('update', {
// 						tab : currTab,
// 						options : {
// 							href:href
// 						}
// 					});
// 				}
// 				currTab.panel('refresh');
// 			}
		}
		/**
		* Name 移除菜单选项
		*/
		function removeTab(){
			var tabPanel = $('#wu-tabs');
			var tab = tabPanel.tabs('getSelected');
			if (tab){
				var index = tabPanel.tabs('getTabIndex', tab);
				tabPanel.tabs('close', index);
			}
		}
	</script>
</body>
</html>
